﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AMS.From
{
    public partial class AddAccount : Form
    {
        AMS.Model.AccountInfo account = new AMS.Model.AccountInfo();
        AMS.Business.AccountInfoBLL business = new AMS.Business.AccountInfoBLL();
        public AddAccount()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string accountname = this.textBox1.Text.Trim();
            string password = this.textBox2.Text.Trim();
            string email = this.textBox3.Text.Trim();
            string ccemail = this.textBox4.Text.Trim();
            string answer1 = this.textBox5.Text.Trim();
            string answer2 = this.textBox6.Text.Trim();
            string answer3 = this.textBox7.Text.Trim();
            string answer4 = this.textBox8.Text.Trim();
            string username = this.textBox9.Text.Trim();
            account.AccountName = accountname;
            account.PassWord = password;
            account.Email = email;
            account.CCEmail = ccemail;
            account.Answer1 = answer1;
            account.Answer2 = answer2;
            account.Answer3 = answer3;
            account.Answer4 = answer4;
            account.UserName = username;

            if (string.IsNullOrEmpty(account.AccountName) || string.IsNullOrEmpty(account.Answer1) || string.IsNullOrEmpty(account.Answer2) || string.IsNullOrEmpty(account.Answer3) || string.IsNullOrEmpty(account.Answer4) || string.IsNullOrEmpty(account.CCEmail) || string.IsNullOrEmpty(account.Email) || string.IsNullOrEmpty(account.PassWord) || string.IsNullOrEmpty(account.UserName))
            {
                MessageBox.Show("字段请不要为空");
            }
            else
            {
                if (business.IsExist(accountname))
                {
                    MessageBox.Show("此用户已存在");
                }
                else
                {

                    business.AccountAdd(account);
                    MessageBox.Show("添加完毕");
                    this.textBox1.Clear();
                    this.textBox2.Clear();
                    this.textBox3.Clear();
                    this.textBox4.Clear();
                    this.textBox5.Clear();
                    this.textBox6.Clear();
                    this.textBox7.Clear();
                    this.textBox8.Clear();
                    this.textBox9.Clear();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void AddAccount_Load(object sender, EventArgs e)
        {

        }
    }
}
